#include <bits/stdc++.h>
using namespace std;

int gcd(int a,int b)
{
	if(b==0)
	{
		return 1000;
	} 
	if(b==1)
	{
		return a-1;
	}
	else
	{
		return gcd(b,a%b)+a/b;
	}
}

int main()
{
    int n;
	cin >> n;
	int count=1e8;
	for(int i=1;i<=n;i++)
	{
	    count=min(count,gcd(n,i));
	}
	cout << count << endl;
	return 0;
}
